﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AppExtensions.Extensions
{
  public static class PropertyDictionaryCreator
  {
      public static Dictionary<string, object> ToPropertyHash(this object item)
      {
        var props = from property in item.GetType().GetProperties()
                    select new {Name=property.Name, Value=property.GetValue(item, null)};
        
        var dict = new Dictionary<string, object>();
        
        foreach(var prop in props)
        {
          dict.Add(prop.Name, prop.Value);  
        }

        return dict;
      }
  }
}
